//
//  BookstoreAPI.swift
//  SLQuickReader
//
//  Created by ALin on 2017/8/3.
//  Copyright © 2017年 ALin. All rights reserved.
//

import UIKit
import Moya
import RxSwift
import SwiftyJSON


let BookstoreProvider = RxMoyaProvider<BookstoreAPI>()

enum BookstoreAPI {
    case statistics // 所有分类
    case recommend // 推荐
    case ranking // 排行榜
    case rankingdetail(String) // 榜单详情
    case bookdetail(String)
}

extension BookstoreAPI: TargetType{
    
    var baseURL: URL { return URL(string: BaseApi)! }
    /*
     // 小说简介(书籍详情)
     http://api.zhuishushenqi.com/book/51d11e782de6405c45000068
     
     // 点击简介的标签跳转
     http://api03icqj.zhuishushenqi.com/book/by-tags?tags=东方玄幻&start=0&limit=100
     
     // 热门评论
     http://api.zhuishushenqi.com/post/review/best-by-book?book=5816b415b06d1d32157790b1
     
     // 可能感兴趣
     http://api.zhuishushenqi.com/book/5816b415b06d1d32157790b1/recommend
     
     // 更多感兴趣的
     http://api03icqj.zhuishushenqi.com/book/5816b415b06d1d32157790b1/recommend
     
     // 推荐书单
     http://api.zhuishushenqi.com/book-list/5816b415b06d1d32157790b1/recommend?limit=3
     
     社区>讨论
     http://api.zhuishushenqi.com/post/by-book?book=5816b415b06d1d32157790b1&sort=updated&type=normal,vote&start=0&limit=20
     
     社区>书评
     http://api.zhuishushenqi.com/post/review/by-book?book=5816b415b06d1d32157790b1&sort=updated&start=0&limit=20
     
     社区->评论>详情
     http://api.zhuishushenqi.com/post/review/581b3700be9018985f28e6de?keepImage=1
    */
    var path: String {
        switch self {
        case .statistics:
            return "/cats/lv2/statistics"
        case .recommend:
            return "/recommend/footer/book"
        case .ranking:
            return "/ranking/gender"
        case .rankingdetail(let id):
            return "/ranking/\(id)"
        case .bookdetail(let id):
            return "/book/\(id)"
        }
    }
    
    var method: Moya.Method {
        return .get
    }
    
    var parameters: [String: Any]? {
        return nil
    }
    
    var parameterEncoding: ParameterEncoding {
        return URLEncoding.default
    }
    
    var sampleData: Data { return Data() }
    
    var task: Task { return .request }
    
    var validate: Bool { return true }

}
